package com.easy;

import com.poidemo.ExcelModel;
import com.poidemo.IExcelOperate;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.read.builder.ExcelReaderBuilder;
import com.alibaba.excel.read.metadata.ReadSheet;
import com.alibaba.excel.read.metadata.ReadWorkbook;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.alibaba.excel.write.metadata.WriteWorkbook;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.List;

/**
 * @author: zhb
 * @time: 2021/3/15 16:01
 */
public class EasyExcelUtil<T> implements IExcelOperate {
    private static final String EXCEL_XLS = "xls";
    private static final String EXCEL_XLSX = "xlsx";
    private ExcelModel excelModel;
    private Class tClass;
    private ReadWorkbook readWorkbook;
    private ReadSheet readSheet;
    private WriteSheet writeSheet;
    private WriteWorkbook writeWorkbook;

    @Override
    public void load(String fileName) {
        readWorkbook = new ReadWorkbook();
        EasyExcel.read();
    }

    public static ReadWorkbook getWorkbook(File file) throws IOException {
        ReadWorkbook rw = null;
        FileInputStream in = new FileInputStream(file);
        if (file.getName().endsWith(EXCEL_XLS)) {
            // Excel 2003
            ExcelReaderBuilder read = EasyExcel.read(in);

        } else if (file.getName().endsWith(EXCEL_XLSX)) {
            // Excel 2007/2010

        }
        return rw;

    }

    @Override
    public <T> List<T> readExcel() {
        return null;
    }

    @Override
    public void splitExcel() {

    }

    @Override
    public void splitExcelThread() {

    }

    @Override
    public void close() {

    }
}
